#!/usr/bin/perl -w
# Task B (3 points)
# Create subroutine that takes two DNA sequences as arguments. 
# The subroutine should determine and compare the lengths of the sequences. 
# Following this, the length of the longest sequence should be returned. 
# Write a program takes two DNA sequences as input from the user, calls the 
# subroutine with the sequences as arguments and saves the return value in 
# a variable. Finally, print the returned value to the command prompt.
#
use warnings;
use strict;
# Forward declare the routine that returns the longest of two sequences
sub get_longest_of_two;

# Get two DNA sequences from user
print "Please give the first DNA sequence ";
our $seq1 = <STDIN>;chomp($seq1);
print "Please give the second DNA sequence ";
my $seq2 =  <STDIN>;chomp($seq2);

# Put the longest sequence in a new variable
my $longest = get_longest_of_two($seq1, $seq2);

# Write out the longest sequence
print("The longest string is: $longest\n"); 


sub get_longest_of_two{
	# Put the arguments into variables
	my $s1 = shift(@_);
	my $s2 = shift(@_);
	# Check whether s2 is longer than s1
	my $short = $s1;
    my $long  = $s2;
    # Compare the two sequences' length
    if (length($s1) > length($s2)){
        return $s1;    
    }
    return $s2;
}

